	Ext.BLANK_IMAGE_URL = "../script/ext-2.0.2/resources/images/default/s.gif"; 		
	var storeParameterManage = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
        	url: 'parameterSingle!getList.action?dateTime='+new Date().getTime()
        }),
        reader: new Ext.data.JsonReader({
            root: 'ZANY',
            totalProperty: "results",
            fields:["id","paramCode","paramName","paramVal"]
        }),
        remoteSort: true
    });
    
    storeParameterManage.load();
    
	var sm = new Ext.grid.CheckboxSelectionModel();
	
	var colParameterManage=new Ext.grid.ColumnModel([sm,
		{header:"参数代码",dataIndex:"paramCode",width:100,sortable:true},
		{header:"参数名",dataIndex:"paramName",width:200,sortable:true},
		{header:"参数值",dataIndex:"paramVal",width:200,sortable:true}
		]);
		

	var parameterManage = new Ext.grid.GridPanel({
		id:'parameterManage',
		title :'[单值参数]信息维护',
		height:500,
		stripeRows :true,
		bodyStyle:'width:100%',
        disableSelection:true,
		cm: colParameterManage,
		viewConfig: {
            forceFit: false
        },
		store: storeParameterManage,
		iconCls: 'details',
		animCollapse: true,
		trackMouseOver:false, 
        loadMask: {msg:'正在加载[单值参数]信息，请稍侯……'},
		selModel:sm, 
		tbar:['-',{text:'&nbsp;&nbsp;添&nbsp;&nbsp;加&nbsp;&nbsp;',iconCls:'add',handler: insertinfo},
			  '-',{text:'&nbsp;&nbsp;删&nbsp;&nbsp;除&nbsp;&nbsp;',iconCls:'remove',handler: delinfo}
		],
		bbar: new Ext.PagingToolbar({
	            pageSize: 20,
	            store: storeParameterManage,
	            displayInfo: true,
	        	emptyMsg:'没有记录'
	        })
	});
	
	function delinfo(){
		if (Ext.getCmp("parameterManage").getSelectionModel().hasSelection()) {
			Ext.MessageBox.confirm('Message','请问您真的要删除所选数据么？',function(btn){
        	if(btn == 'yes'){	
	            var ids = new Array();
	            var records = Ext.getCmp("parameterManage").getSelectionModel().getSelections();
	            for (var i = 0, len = records.length; i < len; i++) {
	                ids[i] = records[i].data["paramCode"];
	            }
	            Ext.Ajax.request({url:'parameterSingle!delete.action?dateTime='+new Date().getTime(),
	                params:{delId:ids},
	                success:function(response, options){
	                   var response = Ext.util.JSON.decode(response.responseText);
						if(response.success){
					        Ext.getCmp('parameterManage').getStore().reload(); 
	                    	ZANY.util.Msg('信息',"删除单值参数信息成功！");
						}else if(!response.success){
							ZANY.util.Msg('信息',"删除单值参数信息失败，如有问题请联系系统管理员！"+response.msg);  
						}             
	                }
	        	});
			}
		})}else{
			ZANY.util.Msg('提示信息',"请选择单值参数信息后再删除！");   
		}
	}
	
	function getList(){
		var params={};
	    storeParameterManage.load({
	    	callback : function(r, options, success) {   
		        if (success == false) {   
		            Ext.Msg.alert("错误", storeParameterManage.reader.jsonData.msg);
		        }   
		    }
		});
	}
    
	var fp = new Ext.FormPanel({
						id:'ext_form',
				        labelWidth: 100, 
				        waitMsg:'正在提交，请稍后...',
				        frame:true,
				        bodyStyle:'padding:5px 5px 0',
				        width: 400,
				        reader: new Ext.data.JsonReader({
				            root: 'ZANY',
				            totalProperty: "results",
				            fields:["id","paramCode","paramName","paramVal"]
				        }),
				        items: [{
				        		 layout:'column',
							     layout: 'form',
							     defaultType: 'textfield',
							     items: [
							     		 {
										 	fieldLabel: '参数代码',
											name: 'paramCode',
											id:'paramCode',
											maxLength:20,
											anchor:'95%',
											allowBlank: false
				                		 },
				                		 {
										 	fieldLabel: '参数名',
											name: 'paramName',
											id:'paramName',
											maxLength:50,
											anchor:'95%',
											allowBlank: false
				                		 },
				                		 {
										 	fieldLabel: '参数值',
											name: 'paramVal',
											id:'paramVal',
											maxLength:50,
											anchor:'95%',
											allowBlank: false
				                		 },
						                 new Ext.form.Hidden({name:'flag'})
								        ]
				        }]
	    			});
	    			
	var winKey =new Ext.Window({
						id:"ext_win",
        				title: '[单值参数信息]',
						width:400,
						closeAction:'hide',
						modal:true,
						iconCls: 'add',
						buttons: [{
				            text: '提交',
				            handler: function(){
				            	if(fp.form.isValid()){
				            		fp.form.submit({
					                    url: 'parameterSingle!insert.action?dateTime='+new Date().getTime(),
										waitTitle:"维护单值参数信息",
					                    waitMsg: '正在提交数据,请稍后... ...',
					                    success: function(){
											Ext.getCmp('parameterManage').getStore().reload(); //刷新Grid
											fp.form.reset();
							                storeParameterManage.modified = [];
											Ext.MessageBox.alert('提示信息', '维护单值参数信息成功！'); 
											winKey.hide();
										},
										failure:function(form,action){
											Ext.MessageBox.alert('提示信息', '维护单值参数信息失败,请联系系统管理员!'+action.result.msg);
										}
					                });
				            	}else{
				            		ZANY.util.Msg('添加提示','数据不完整！');
				            	}
				            }
				        },{
				            text: '取消',handler: function(){winKey.hide();
				            fp.form.reset();}
				        }],
						items:[fp]	
					});
					
	winKey.addListener("hide",function(){fp.form.reset();});
	
	function insertinfo(){
		winKey.show();	
    }
    
   parameterManage.addListener('rowdblclick',function(e){
    	if (Ext.getCmp("parameterManage").getSelectionModel().hasSelection()) {
    			getDetail();
			}
		},parameterManage
	);
	
	function getDetail(){
		var records = Ext.getCmp("parameterManage").getSelectionModel().getSelected();
		var paramCode =records.data["paramCode"];
		fp.getForm().load({url:'parameterSingle!getList.action?dateTime='+new Date().getTime()+'&paramCode='+paramCode+'&flag=update', waitMsg:'Loading'});
    	winKey.show();
    	fp.getForm().findField("flag").setValue("update");
	}
	
	Ext.onReady(function(){
		Ext.QuickTips.init(); 
	　　 Ext.form.Field.prototype.msgTarget = 'side';
			var port = new Ext.Viewport({
				layout : 'fit',
				frame : true,
				items : [this.parameterManage]
	    	});
	});